<template>
  <!-- max不知道什么时候拿到，所以用watch来监听 -->
  <div class="mui-numbox" data-numbox-min="1" :data-numbox-max="999">
    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
    <!-- 新属性 值改变的时候用@change调用方法 -->
    <input
      id="test"
      class="mui-input-numbox"
      type="number"
      @change="countchanged"
      ref="numbox"
      :value="initcount"
    /><!--readonly-->
    <button class="mui-btn mui-btn-numbox-plus" type="button" disabled="">
      +
    </button>
  </div>
</template>

<script>
import mui from "../../assets/js/mui.min.js";

export default {
  data() {
    return {};
  },
  mounted() {
    //初始化选择框组件
    mui(".mui-numbox").numbox();
  },

  props: ["initcount", "goodsinfoid"],
  methods: {
    countchanged() {
      this.$store.commit("updategoodsinfo", {
        id: this.goodsinfoid,
        count: this.$refs.numbox.value,
      });
    },
  },
};
</script>

<style>
</style>


